import mysql.connector
from mysql.connector import Error


def get_db_connection():
    try:
        connection = mysql.connector.connect(
            host='localhost',
            database='intelligent_retail',
            user='root',
            password='123456'
        )
        print("数据库链接成功！")
        return connection
    except Error as e:
        print(f"数据库连接错误: {e}")
        return None


if __name__ == '__main__':
    get_db_connection()